<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
$(function(){
	var storiedBuildingHome = '${user.getStoriedBuilding()}';
	var roleName = '${roleName}';
	if(roleName!="ADMINISTRATOR" || roleName == null){
		$("#sysManagement").hide();
		$("#announcements").hide();
		$("#peopleRecordHide").hide();
		$("#dormitoryHide").hide();
	}
	$("#iframe").attr("src","homePage.action?storiedBuilding="+storiedBuildingHome);
	
	titleNum();
});

$("#changePassWordDiv").dialog({
	closed:false,
	modal:true,
    width:720,
    height:440
});


function titleNum(){
	var studentId = $("#studentId").val();
	$.ajax({
		type:'POST',
		url:'titleNum.action',
		data:{jStudentId:studentId},
		datatype:'json',
		success:function(data){
			$("#titleNum").html(data.num);
			$("#titleContent").attr("title","您有"+data.num+"条未读消息");
		}
	});
}


$(document).ready(function(){
	$("#changePassWord").click(function(){
		layer.open({
            type: 1,
            title: '修改密码',
            shadeClose: true,
            shade: 0.5,
            skin: 'layui-layer-rim',
//            maxmin: true,
            closeBtn:2,
            area: ['22%', '33%'],
            shadeClose: true,
            closeBtn: 2,
            content: $("#changePassWordDiv")
            //iframe的url
        });
	});
	
	
	$("#saveButtonPassWord").click(function(){
		//alert("1");
		var userName = '${user.userName}';
		var yspw = $("#ysPassWord").val();
		var yipw = $("#yiPassWord").val();
		var erpw = $("#erPassWord").val();
		
		if(yspw!="" && yipw!="" && erpw!=""){
			if(yipw == erpw){
				$.ajax({
					type:'post',
					url:"changePassWordValidation.action",
					data:{userName:userName,passWord:yspw},
					datatype:'json',
					success:function(msg){
						if(msg.state == "200"){
							
							$.ajax({
								type:'post',
								url:"changePassWord.action",
								data:{userName:userName,passWord:yipw},
								datatype:'json',
								success:function(msg){
									if(msg.state>0){
										layer.open({
											type: 0, 
											content: '成功'
										});
										var index = parent.layer.getFrameIndex(window.name);  
										 parent.layer.close(index);//关闭当前页 
									}
								}
							});
						}
						if(msg.state=="500"){
							layer.open({
								type: 0, 
								content: '原始密码不正确,请重新输入'
							});
						}
					}
				});
			}else{
				layer.open({
					type: 0, 
					content: '两次密码不一致'
				});
			}
		}
	});
});

function UserManagement(){
	var storiedBuilding = $("#storiedBuilding").val();
	$("#UserManagement").attr("href","UserManagement.action?storiedBuilding="+storiedBuilding);
	//$("#dialogIframe").attr("src","<c:url value='/schedule/show' />?judge="+judge+"&id="+$("input[name='id']:checked").val());
}

function homePage(){
	var storiedBuilding = $("#storiedBuilding").val();
	$("#homePage").attr("href","homePage.action?storiedBuilding="+storiedBuilding);
}

function createAnnouncement(){
	var storiedBuilding = $("#storiedBuilding").val();
	$("#createAnnouncement").attr("href","createAnnouncement.action?storiedBuilding="+storiedBuilding+"&type=公告");
}																	

function createNotice(){
	var storiedBuilding = $("#storiedBuilding").val();
	$("#createNotice").attr("href","createAnnouncement.action?storiedBuilding="+storiedBuilding+"&type=通知");
}

/*function announcementsList(){
	alert("1");
	var storiedBuilding = $("#storiedBuilding").val();
	$("#announcementsList").attr("href","GetAnnouncementList.action?storiedBuilding="+storiedBuilding);
}*/





